.. _Using NeurEcoPFS:

Tutorial: using NeurEco command line interface for a Parametric Frequency Sweep problem
########################################################################################

**NeurEcoFNN** is the executable used for building, evaluating and exporting **Frequency Domain** models (**Parametric Frequency Sweep**). The executable can be called directly from a terminal / powershell only after a full installation (the portable version doesn't allow this option).
To call the executable, run the following command:

.. code-block:: shell

	neurecoFNN

which will output:

.. code-block:: text

  Running NeurEco Frequential version 3.0.616.0 compiled with MSVC v1928  on Apr  3 2023 @ 16:53:14
  usage: neurecoRNN [-h] [command <parameters>]

  Entry point for neurecoRNN network building and evaluation.

  Commands:
  build <configurationFilename>
        build a neurecoFNN network from a given input solution/excitation set.

  evaluate <configurationFilename>
        evaluate a neurecoFNN network from a given input solution/excitation set.

  exportFMU <FMU model full path> <serialized network full path> <ORed platform flag (windows=1, linux=2)>
        export a serialized network as an FMU file.

  Optional arguments:
  -h, --help   show this message and exit

The following section uses the test case :std:ref:`FSS test case conf`. This test case is delivered with the NeurEco installation package.

To build a **Parametric Frequency Sweep** model using the executable:

* Create a configuration file *.conf* for build, here called *build_configuration_file.conf* (see :std:ref:`Build NeurEco Parametric Frequency Sweep model with the command line interface`). 
  For the test case :std:ref:`FSS test case conf`, the configuration file for build looks, for example, as follows:

.. code-block:: javascript

    {"neurecoFNN_build": {
        "AdvancedSettings": {
        },
        "checkpoint_address": "./fssModel/fss_model.checkpoint",
        "input_filenames": [
            "./inputs_train.npy"
        ],
        "output_filenames": [
            "./targets_train.npy"
        ],
        "resume": false,
        "settings": {
            "compressed_space_size": 5,
            "enrichment_rate": 0.2,
            "max_number_of_enrichments": 200,
            "min_number_of_enrichments": 10,
            "unsuccessful_enrichments": 4,
            "validation_percentage": 30
        },
        "test_input_filenames": [
            "./inputs_test.npy"
        ],
        "test_output_filenames": [
            "./targets_test.npy"
        ],
        "validation_input_filenames": [
            "./inputs_valid.npy"
        ],
        "validation_output_filenames": [
            "./targets_valid.npy"
        ],
        "write_model_to": "./fssModel/fss_model.efnn"
    }

* Place this configuration file in the same directory as the data of the test case (*inputs_train.npy*, *inputs_valid.npy*, *inputs_test.npy*, *targets_train.npy*, *targets_valid.npy*, *targets_test.npy*), otherwise adjust the relative paths to the data files in the configuration file.

* To launch the build, run the following command in the terminal (opened in the data directory, otherwise adjust the relative path to the configuration file):

.. code-block:: shell

	neurecoFNN build ./build_configuration_file.conf

* The build starts automatically:

.. code-block:: text

  00h00m00s info > Running NeurEco Frequential version 3.0.616.0 compiled with MSVC v1928  on Apr  3 2023 @ 16:53:14
  00h00m00s info > Reading Dataset...

To evaluate a **Parametric Frequency Sweep** model using the executable:

* Create a configuration *.conf* file for evaluation, here called *eval_configuration_file.conf* (see :std:ref:`Evaluate NeurEco Parametric Frequency Sweep model with the command line interface`). 
  For the test case :std:ref:`FSS test case conf`, the configuration file for evaluation looks, for example, as follows:

.. code-block:: javascript

   {
    "neurecoFNN_evaluate": {
        "input_filenames": ["./inputs_test.npy"],
        "neureco_filename": "./fssModel/fss_model.efnn",
        "write_model_output_to_directory": "./EvalResults"
    }
    }

* Place this configuration file in the same directory as the data of the test case (*inputs_test.npy*), otherwise adjust the relative paths to the data files in the configuration file.

* To launch the evaluation, run the following command in the terminal (opened in the data directory, otherwise adjust the relative path to the configuration file):

.. code-block:: shell

	neurecoFNN evaluate ./eval_configuration_file.conf

* The model is evaluated on the testing data in *"./inputs_test.npy"*, and the results are saved in the directory created by NeurEco: *"./EvalResults"*.

To export a **Parametric Frequency Sweep** model to the FMU format using the executable (*neureco_embed_pfs* license is required):

* Run the following command (with 1 for ORed platform flag: windows=1, linux=2):

.. code-block:: shell

	neurecoFNN exportFMU ./fssModel/fss_model.efnn ./fssModel/fss_model.fmu 1
